export class Dept {
  deptId?: number;
  parentId = 0;
  name = '';
  parentName = '';
  orderNum = 0;

  constructor(data?: Dept) {
    data && this.setProps(data)
  }

  setProps(data: Dept) {
    (Object.keys(this) as Array<keyof IDept>).forEach(key => {
      // @ts-ignore
      this[key] = data[key]
    })
  }
}

export type IDept = Omit<Dept, 'setProps'> & {
  deptId: number;
  children?: IDept[]
}

export type IFlatDept = {
  id: number;
  value: number;
  pId: number;
  title: string;
}